//vat typeText = <li class=\"menu-item menu-item-has-children has-mega-menu\"><a href=\"#\">一级类型</a>
//<div class=\"mega-menu\">
//    <div class=\"mega-wrap\">
//        <div class=\"mega-column\">
//            <ul class=\"mega-item mega-features\">
//                <li><a href=\"product-listing.html\">二级类型</a></li>
//                <li><a href=\"product-listing.html\">二级类型</a></li>
//            </ul>
//        </div>
//        <div class=\"mega-column\">
//            <h4 class=\"mega-heading\">二级类型</h4>
//            <ul class=\"mega-item\">
//                <li><a href=\"product-listing.html\">三级类型</a></li>
//                <li><a href=\"product-listing.html\">三级类型</a></li>
//            </ul>
//        </div>
//    </div>
//</div>
//</li>;
/*var bannerText = "<li class=\"ps-banner\" data-index=\"";
bannerText+="rs-900";
bannerText+="\" data-transition=\"random\" data-slotamount=\"default\" data-hideafterloop=\"0\" data-hideslideonmobile=\"off\" data-rotate=\"0\"><img class=\"rev-slidebg\" src=\""+"images/background/parallax.jpg"+"\" alt=\"\" data-bgposition=\"center center\" data-bgfit=\"cover\" data-bgrepeat=\"no-repeat\" data-bgparallax=\"5\" data-no-retina><div class=\"tp-caption ps-banner__header\" id=\"layer-1\" data-x=\"left\" data-hoffset=\"['-60','15','15','15']\" data-y=\"['middle','middle','middle','middle']\" data-voffset=\"['-150','-120','-150','-170']\" data-width=\"['none','none','none','400']\" data-type=\"text\" data-responsive_offset=\"on\" data-frames=\"[{&quot;delay&quot;:1000,&quot;speed&quot;:1500,&quot;frame&quot;:&quot;0&quot;,&quot;from&quot;:&quot;x:50px;opacity:0;&quot;,&quot;to&quot;:&quot;o:1;&quot;,&quot;ease&quot;:&quot;Power3.easeInOut&quot;},{&quot;delay&quot;:&quot;wait&quot;,&quot;speed&quot;:300,&quot;frame&quot;:&quot;999&quot;,&quot;to&quot;:&quot;x:50px;opacity:0;&quot;,&quot;ease&quot;:&quot;Power3.easeInOut&quot;}]\"><p>";
bannerText+="后台加的主标题";
bannerText+="</p></div><div class=\"tp-caption ps-banner__title\" id=\"layer21\" data-x=\"['left','left','left','left']\" data-hoffset=\"['-60','15','15','15']\" data-y=\"['middle','middle','middle','middle']\" data-voffset=\"['-60','-40','-50','-70']\" data-type=\"text\" data-responsive_offset=\"on\" data-textAlign=\"['center','center','center','center']\" data-frames=\"[{&quot;delay&quot;:1200,&quot;speed&quot;:1500,&quot;frame&quot;:&quot;0&quot;,&quot;from&quot;:&quot;x:50px;opacity:0;&quot;,&quot;to&quot;:&quot;o:1;&quot;,&quot;ease&quot;:&quot;Power3.easeInOut&quot;},{&quot;delay&quot;:&quot;wait&quot;,&quot;speed&quot;:300,&quot;frame&quot;:&quot;999&quot;,&quot;to&quot;:&quot;x:50px;opacity:0;&quot;,&quot;ease&quot;:&quot;Power3.easeInOut&quot;}]\"> <p class=\"text-uppercase\">";
bannerText+="后台加的副标题";
bannerText+="</p></div><div class=\"tp-caption ps-banner__description\" id=\"layer211\" data-x=\"['left','left','left','left']\" data-hoffset=\"['-60','15','15','15']\" data-y=\"['middle','middle','middle','middle']\" data-voffset=\"['30','50','50','50']\" data-type=\"text\" data-responsive_offset=\"on\" data-textAlign=\"['center','center','center','center']\" data-frames=\"[{&quot;delay&quot;:1200,&quot;speed&quot;:1500,&quot;frame&quot;:&quot;0&quot;,&quot;from&quot;:&quot;x:50px;opacity:0;&quot;,&quot;to&quot;:&quot;o:1;&quot;,&quot;ease&quot;:&quot;Power3.easeInOut&quot;},{&quot;delay&quot;:&quot;wait&quot;,&quot;speed&quot;:300,&quot;frame&quot;:&quot;999&quot;,&quot;to&quot;:&quot;x:50px;opacity:0;&quot;,&quot;ease&quot;:&quot;Power3.easeInOut&quot;}]\"><p>";
bannerText+="后台加的描述";
bannerText+="</p></div><a class=\"tp-caption ps-btn\" id=\"layer31\" href=\"#\" data-x=\"['left','left','left','left']\"data-hoffset=\"['-60','15','15','15']\" data-y=\"['middle','middle','middle','middle']\" data-voffset=\"['120','140','200','200']\" data-type=\"text\" data-responsive_offset=\"on\" data-textAlign=\"['center','center','center','center']\" data-frames=\"[{&quot;delay&quot;:1500,&quot;speed&quot;:1500,&quot;frame&quot;:&quot;0&quot;,&quot;from&quot;:&quot;x:50px;opacity:0;&quot;,&quot;to&quot;:&quot;o:1;&quot;,&quot;ease&quot;:&quot;Power3.easeInOut&quot;},{&quot;delay&quot;:&quot;wait&quot;,&quot;speed&quot;:300,&quot;frame&quot;:&quot;999&quot;,&quot;to&quot;:&quot;x:50px;opacity:0;&quot;,&quot;ease&quot;:&quot;Power3.easeInOut&quot;}]\">立即抢购<i class=\"ps-icon-next\"></i></a></li>";
$("#home-banner ul").append(bannerText);*/
// $.getJSON("/getBanerInfo", function(data){
//   $.each(data, function(i,item){
//     $("#home-banner").append("<li class=\"ps-banner\" data-index=\""+item.goodsid+"\" data-transition=\"random\" data-slotamount=\"default\" data-hideafterloop=\"0\" data-hideslideonmobile=\"off\" data-rotate=\"0\">
//     <img class=\"rev-slidebg\" src=\""+item.img+"\" alt=\"\" data-bgposition=\"center center\"
//         data-bgfit=\"cover\" data-bgrepeat=\"no-repeat\" data-bgparallax=\"5\" data-no-retina>
//     <div class=\"tp-caption ps-banner__header\" id=\"layer-1\" data-x=\"left\"
//         data-hoffset=\"['-60','15','15','15']\" data-y=\"['middle','middle','middle','middle']\"
//         data-voffset=\"['-150','-120','-150','-170']\" data-width=\"['none','none','none','400']\"
//         data-type=\"text\" data-responsive_offset=\"on\"
//         data-frames=\"[{&quot;delay&quot;:1000,&quot;speed&quot;:1500,&quot;frame&quot;:&quot;0&quot;,&quot;from&quot;:&quot;x:50px;opacity:0;&quot;,&quot;to&quot;:&quot;o:1;&quot;,&quot;ease&quot;:&quot;Power3.easeInOut&quot;},{&quot;delay&quot;:&quot;wait&quot;,&quot;speed&quot;:300,&quot;frame&quot;:&quot;999&quot;,&quot;to&quot;:&quot;x:50px;opacity:0;&quot;,&quot;ease&quot;:&quot;Power3.easeInOut&quot;}]\">
//         <p>"+item.head+"</p>
//     </div>
//     <div class=\"tp-caption ps-banner__title\" id=\"layer21\" data-x=\"['left','left','left','left']\"
//         data-hoffset=\"['-60','15','15','15']\" data-y=\"['middle','middle','middle','middle']\"
//         data-voffset=\"['-60','-40','-50','-70']\" data-type=\"text\" data-responsive_offset=\"on\"
//         data-textAlign=\"['center','center','center','center']\"
//         data-frames=\"[{&quot;delay&quot;:1200,&quot;speed&quot;:1500,&quot;frame&quot;:&quot;0&quot;,&quot;from&quot;:&quot;x:50px;opacity:0;&quot;,&quot;to&quot;:&quot;o:1;&quot;,&quot;ease&quot;:&quot;Power3.easeInOut&quot;},{&quot;delay&quot;:&quot;wait&quot;,&quot;speed&quot;:300,&quot;frame&quot;:&quot;999&quot;,&quot;to&quot;:&quot;x:50px;opacity:0;&quot;,&quot;ease&quot;:&quot;Power3.easeInOut&quot;}]\">
//         <p class=\"text-uppercase\">"+item.subhead+"</p>
//     </div>
//     <div class=\"tp-caption ps-banner__description\" id=\"layer211\"
//         data-x=\"['left','left','left','left']\" data-hoffset=\"['-60','15','15','15']\"
//         data-y=\"['middle','middle','middle','middle']\" data-voffset=\"['30','50','50','50']\"
//         data-type=\"text\" data-responsive_offset=\"on\"
//         data-textAlign=\"['center','center','center','center']\"
//         data-frames=\"[{&quot;delay&quot;:1200,&quot;speed&quot;:1500,&quot;frame&quot;:&quot;0&quot;,&quot;from&quot;:&quot;x:50px;opacity:0;&quot;,&quot;to&quot;:&quot;o:1;&quot;,&quot;ease&quot;:&quot;Power3.easeInOut&quot;},{&quot;delay&quot;:&quot;wait&quot;,&quot;speed&quot;:300,&quot;frame&quot;:&quot;999&quot;,&quot;to&quot;:&quot;x:50px;opacity:0;&quot;,&quot;ease&quot;:&quot;Power3.easeInOut&quot;}]\">
//         <p>"+item.desc+"</p>
//     </div><a class=\"tp-caption ps-btn\" id=\"layer31\" href=\"#\" data-x=\"['left','left','left','left']\"
//         data-hoffset=\"['-60','15','15','15']\" data-y=\"['middle','middle','middle','middle']\"
//         data-voffset=\"['120','140','200','200']\" data-type=\"text\" data-responsive_offset=\"on\"
//         data-textAlign=\"['center','center','center','center']\"
//         data-frames=\"[{&quot;delay&quot;:1500,&quot;speed&quot;:1500,&quot;frame&quot;:&quot;0&quot;,&quot;from&quot;:&quot;x:50px;opacity:0;&quot;,&quot;to&quot;:&quot;o:1;&quot;,&quot;ease&quot;:&quot;Power3.easeInOut&quot;},{&quot;delay&quot;:&quot;wait&quot;,&quot;speed&quot;:300,&quot;frame&quot;:&quot;999&quot;,&quot;to&quot;:&quot;x:50px;opacity:0;&quot;,&quot;ease&quot;:&quot;Power3.easeInOut&quot;}]\">立即抢购
//         <i class=\"ps-icon-next\"></i></a>
// </li>");    
//   });
// });

$(function(){
	    //动态获取类别
	
	
	
	$.post("GoodsTypeServlet",function(msg){
		var obj= JSON.parse(msg);
		   
	     for(i=0;i<obj.length;i++){
	    	var text1 ="<li class=\"menu-item menu-item-has-children has-mega-menu\"><a href=\"#\">"+obj[i].typename+"</a>"
	    	
	    	if(obj[i].subtype.length>0){
	    		text1+="<div class=\"mega-menu\">";
   			text1+="<div class=\"mega-wrap\">";
   			text1+="<ul class=\"mega-item mega-features\">";
	    		for(j=0;j<obj[i].subtype.length;j++){
	    			
	    			text1+="<li><a href=\"product-listing.html\">"+obj[i].subtype[j].typename+"</a></li>"
	    		}
	    		text1+="</ul> </div>     </div> </div> </li>";
	    	}
	    	
	    	$("#centermenu").append(text1);
	     }
		
	})
	
	$.post("CartGoods",{ method : "getAllGoods" },
			function(data){
		
		if(data==null)
			return;
		
		var goods = JSON.parse(data);
		
		$("#qualitynum").html("<i>"+goods.length+"</i>");
		
		var totalspent = 0;
		
		for(i=0;i<goods.length;i++){
			var text = "<div class=\"ps-cart-item\"><a class=\"ps-cart-item__close\" href=\"CartGoods?method=changeQuantity&goodsid="+goods[i].goodsid+"&goodsnum=-1\"></a>\r\n" + 
			"<div class=\"ps-cart-item__thumbnail\"><a href=\"product-detail.html\"></a><img\r\n" + 
			"src=\""+ goods[i].goodsrc + "\" alt=\"\"></div>\r\n" + 
			"<div class=\"ps-cart-item__content\"><a class=\"ps-cart-item__title\"\r\n" + 
			"href=\"product-detail.html\">"+ goods[i].goodsname  +"</a>\r\n" + 
			"<p><span>Quantity:<i>"+goods[i].goodsnum+ "</i></span><span>Total:<i>"+ (goods[i].goodsnum * goods[i].price).toFixed(2) +"</i></span></p>\r\n" + 
			"</div>\r\n" + 
			"</div>"
				
			
			totalspent+=goods[i].goodsnum * goods[i].price;

			$("#cart_content").append(text);
		}
			
		$("#items").text(goods.length);
		$("#total").text("$"+(totalspent.toFixed(2)));
	});
	
	
	
	
	$(".ps-cart-item__close").click(function (){
		
		$(this).remove();
		
	})
	
})	